package jml.defaultimple.web;

import java.net.URLDecoder;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jml.config.Config;
import jml.config.cmd.Command;
import jml.config.cmd.CommandExec;
import jml.config.cmd.CommandGroup;

@WebServlet("/explore")
public class ServletExplorer extends HttpServlet
{
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException
	{
		// recibo el path del title a tocar
		String titlePath = request.getParameter("path");
		String titlePathOK = URLDecoder.decode(titlePath, "UTF-8");
		
//		ExternalCommands ec =Config.getConfig(false).getExternalCommands();		
//		Explorer ex = ec.getExplorer();
//		
//		ArrayList<String> args = new ArrayList<String>();		
//		args.add(ec.getRuntimeScript());
//		args.add(ec.getDefaultScript());			
//		args.add(ex.getPath());
//		args.add("\""+titlePathOK+"\"");
//		ProcessBuilder pb = new ProcessBuilder(args);
//		pb.start();

		CommandGroup cg = Config.getConfig(false).getCommandGroup();
		Command e = cg.getComnand("EXPLORER","default");
		e.getAppParams().put("TITLEPATH",titlePathOK);
		CommandExec.exec(e);
		
		
		
		return;
	}
}
